<?php


namespace app\api\controller\v1;


use app\api\model\Banner as BannerModel;
use app\api\vaildate\IDMustBePostiveInt;
use app\lib\exception\BannerMissException;

class Banner
{
    /*
     * 获取指定id的banner数据
     * @url /getbanner/:id
     * @http GET
     * @id banner的id
     */
    public function getBanner($id)
    {
        (new IDMustBePostiveInt())->goCheck();
        $banner = BannerModel::with('items,items.img')->find($id);
        if (!$banner){
            throw new BannerMissException();
        }
        return $banner;
    }
}